package com.liang.exam.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liang.exam.entity.Exam;
import com.liang.exam.entity.Student;
import com.liang.exam.mapper.StudentMapper;
import com.liang.exam.service.StudentService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Resource
    public StudentMapper studentMapper;



    @Override
    public Student findByAccount(String account) {
        return studentMapper.findByAccount(account);
    }

    @Override
    public Student findByIpAddress(String ipAddress) {
        return studentMapper.findByIpAddress(ipAddress);
    }

    @Override
    public Student findById(int id) {
        return studentMapper.findById(id);
    }

    @Override
    public void save(String ipAddress, int id) {
        studentMapper.save(ipAddress, id);
    }

    @Override
    public PageInfo<Exam> examList(Integer pageNum, Integer pageSize, String account,String ExamName) {
        PageHelper.startPage(pageNum,pageSize);
        List<Exam> exam = studentMapper.examList(account,ExamName);
        PageInfo<Exam> pageInfo = new PageInfo<>(exam);
        return pageInfo;
    }

    @Override
    public void uploadStudentAnswer(Exam exam) {
        studentMapper.uploadStudentAnswer(exam);
    }
}
